{% if post.author %}
  {% assign author = post.author %}
{% elsif page.author %}
  {% assign author = page.author %}
{% else %}
  {% assign author = site.author %}
{% endif %}
{% if author %}
    <span class="author">Posted by
        {% assign the_author = site.data.authors | where: 'id', author %}
        {% for author in the_author %}
            <a href="{{ site.author_dir | prepend: site.baseurl | replace: '//', '/' }}/{{ author.id }}">
                {% if author.name %}
                    {{ author.name }}
                {% else %}
                    {{ author.id }}
                {% endif %}
            </a>
        {% endfor %}
    </span>
{% endif %}
